package com.hsd.survey.action;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hsd.survey.service.ISurveyCommonService;
import com.hsd.survey.service.ISurveyDesignService;

/**
 * <p>
 * 类描述：问卷逻辑设计
 * <p>
 * 创建人：Abdi
 * <p>
 * 创建时间：Nov 16, 2013 2:43:15 PM
 */
@Controller
@RequestMapping("/logic")
public class SurveyLogicAction {
	@Autowired
	private ISurveyCommonService commonService;
	@Autowired
	private ISurveyDesignService designService;
	
	/**
	 * 加载逻辑设计使用数据
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/loadLogicData.do",produces = {"application/json;charset=UTF-8"})
	public @ResponseBody String loadLogicData(HttpServletRequest request,ModelMap model){
		String surveyuuid = request.getParameter("surveyuuid");
		surveyuuid = "0aa137b2-1f9f-4e6f-81e4-b34caca1284b";
		String logicData = commonService.loadLogicData(surveyuuid).toString();
		System.out.println("==========>>> logicData " + logicData);
		return logicData;
	}
	
	/**
	 * 保存问卷逻辑
	 * @param request
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/saveLogic.do",produces = {"application/json;charset=UTF-8"})
	public @ResponseBody String saveLogic(HttpServletRequest request,ModelMap model){
		String surveyuuid = request.getParameter("surveyuuid");
		String logiclist = request.getParameter("logiclist");
		
		System.out.println("===========>>>surveyuuid " + surveyuuid);
		System.out.println("===========>>>logiclist " + logiclist);
		
		designService.saveLogic(surveyuuid, logiclist);
		return "保存成功！";
	}
}
